package cn.sytton.taffe.auth.controller;

import cn.sytton.taffe.auth.entity.LoginEntity;
import cn.sytton.taffe.auth.service.ILoginService;
import cn.sytton.taffe.framework.base.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 登录控制层
 *
 * @author skyrock
 */
@Tag(name = "登录")
@RestController
@RequestMapping("/auth/login")
public class LoginController extends BaseController {

    @Resource
    private ILoginService loginService;

    @Operation(summary = "用户密码登录")
    @PostMapping("/pwd")
    public String loginPwd(@RequestBody LoginEntity loginEntity) {
        return loginService.loginByPwd(loginEntity);
    }

    @Operation(summary = "短信验证码登录")
    @PostMapping("/sms")
    public String loginSms(@RequestBody LoginEntity loginEntity) {
        return loginService.loginBySms(loginEntity);
    }
}
